<template>
  <el-container class="allbody" onscroll="false">
  

    <el-main style="height: 100%; z-index: 5">
      <el-row style="width: 100%; height: 10%">
        <el-form
          :inline="true"
          class="demo-form-inline"
          style="margin-top: 20px; margin-left: 10px"
        >
          <el-form-item>
            <el-input
              v-model="Equ"
              class="form-input"
              style="width: 300px"
              disabled
            ></el-input>
          </el-form-item>

          <el-form-item>
            <el-input
              v-model="Sydw"
              class="form-input"
              style="width: 500px"
              disabled
            ></el-input>
          </el-form-item>
          <!-- <el-select v-model="timeValue" @change="selectCheckDate">
            <el-option
              v-for="item in timeOption"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select> -->
          <el-select v-model="structValue" @change="selectStruct">
            <el-option
              v-for="item in structOption"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
              <span>{{ item.value }}</span>
            </el-option>
          </el-select>

          <!-- <el-form-item>
            <el-button style="color: #009bfe" @click="show">查询</el-button>
          </el-form-item> -->
          <el-form-item style="position: absolute; right: 150px">
            <i class="el-icon-back" style="color: black; font-size: 25px"></i>
            <el-button
              type="text"
              style="color: black; font-size: 22px"
              @click="switchList"
              >返回上一级</el-button
            >
          </el-form-item>
        </el-form>
      </el-row>
      <el-row style="height: 100%; width: 100%">
        <div style="height: 100%; width: 100%">
          <monitoring
            :indexOfValue="selectPoint"
            key="0"
            height="400px"
            width="100%"
          ></monitoring>
        </div>
      </el-row>
      <el-row>
        <el-table
          :data="tableData"
          style="
          width:90%
            height: 98%;
            margin-top:-470px
          "
          fit
        >
          <el-table-column width="80">
            <template slot-scope="scope">
              <el-checkbox v-model="scope.row.selected" @change="selectPointChange(scope.row)"></el-checkbox>
            </template>
          </el-table-column>
          <el-table-column prop="Id" label="序号" width="150">
          </el-table-column>
          <el-table-column prop="t001" label="监测对象" width="200">
          </el-table-column>
          <el-table-column prop="t002" label="监测变量"> </el-table-column>
          <el-table-column prop="t003" label="数据类型" width="200">
          </el-table-column>
          <el-table-column prop="t004" label="监测结果（最大值）" width="300">
          </el-table-column>
          <el-table-column prop="t005" label="单位" width="200">
          </el-table-column>
        </el-table>
      </el-row>
    </el-main>
  </el-container>
</template>

<script>
import ElContainer from "element-ui/packages/container/src/main";
import ElAside from "element-ui/packages/aside/src/main";
import ElHeader from "element-ui/packages/header/src/main";
import ElMain from "element-ui/packages/main/src/main";
import Monitoring from "./staticChart.vue";

import { get, get as userType, del, dels } from "@/api/sys/connSysAuthApi";
import { parseTime } from "@/utils";
import { req } from "@/api/base/BaseApi";

import Calendar from "vue-calendar-component";

export default {
  name: "detail",
  components: { Calendar, Monitoring },
  comments: {
    ElMain,
    ElHeader,
    ElAside,
    ElContainer,
  },
  props: {
    detailList: Array,
  },
  methods: {
    dateFormat(time) {
      var date = new Date(time);
      var year = date.getFullYear();
      /* 在日期格式中，月份是从0开始的，因此要加0
       * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
       * */
      var month =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
      var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      var hours =
        date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      var minutes =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      var seconds =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      // 拼接
      return (
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hours +
        ":" +
        minutes +
        ":" +
        seconds
      );
    },
    tableRowStyle({ row, rowIndex }) {
      return {
        "background-color": "#02152f",
        color: "#fff",
      };
    },
    tableHeaderColor({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background-color: #2ec7c9;color: #fff;font-weight: 500;";
      }
    },
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type];
    },
    getRowClass({ row, column, rowIndex, columnIndex }) {
      return {
        background: "#06134A",
        color: "#72C22D",
      };
    },
    selectCheckDate(value) {
      // 根据选中的日期切换报告
      console.log("选中的值是:", value);
      this.checkData = this.checkDataList[+value];
    },
    selectStruct(value) {
      // 选中不同的结构
    },
    show() {
      this.mydate = this.year + "-" + this.month + "-" + this.day;
      console.log(this.mydate);
    },
    switchList() {
      this.$emit("switchList");
    },
    yearChange(id, type) {
      this.year = id;
    },
    monthChange(id, type) {
      this.month = id;
    },
    dayChange(id, type) {
      this.day = id;
    },
    selectPointChange(row){
      console.log('选中了监测点：',row.Id,row.selected)
      if(row.selected==true){
        // 遍历所有行，取消其他行的选中状态
        for(const item of this.tableData){
          if(item.Id!=row.Id){
            item.selected=false;
          }
        }
        // 选中了当前行，进行一些操作
        this.selectPoint=+row.ListId-1;
        // ... ...
      }
      else {
        // 取消选中当前行的操作无效化，同时有且会有一行被选中
        row.selected=true;
      }
    }
  },
  created() {},
  computed: {
    Equ() {
      return "设备编号：" + this.EquValue;
    },
    Sydw() {
      return "使用单位：" + this.SydwValue;
    },
    ifSelected() {
      return (Id) => {
        if (Id == 1) return true;
        else return false;
      };
    },
  },
  data() {
    return {
      EquValue: "一钢轧 008", // 当前设备的（内部）编号
      SydwValue: "马鞍山钢铁股份有限公司", // 当前设备的的使用单位
      timeOption: [
        // 监控数据的时间，按天划分，一天24*60，一分钟取一个数据
      ],
      timeValue: "", // 当前选中的日期
      monitoringData: {}, // 当前选中
      structOption: [
        {
          label: "分类：    主起升",
          value: "主起升",
        },
      ], // 结构可选项
      structValue: "主起升", // 当前选中的结构

      //--------------------------------------------------------
      date: new Date(),
      year: "",
      month: "",
      day: "",
      mydate: "",

      location: "",

      city: "",

      calendar: {},

      //---------------------------------------------------------
      selectPoint: 0, // 选中的监测点的Id
      tableData: [
        // 监测点信息
        {
          Id: 1,
          ListId:1,
          t001: "主起升",
          t002: "主起重量",
          t003: "实数",
          t004: "50.00",
          t005: "吨",
          selected:true,
        },
        {
          Id: 2,
          ListId:2,
          t001: "主起升",
          t002: "主起升高度",
          t003: "实数",
          t004: "13.60",
          t005: "米",
          selected:false,
        },
        {
          Id: 3,
          ListId:3,
          t001: "主起升",
          t002: "单位工作循环时间",
          t003: "实数",
          t004: "12.00",
          t005: "h",
          selected:false,
        },
        {
          Id: 4,
          ListId:4,
          t001: "主起升",
          t002: "工作循环总时间",
          t003: "实数",
          t004: "8192.00",
          t005: "h",
          selected:false,
        },
        {
          Id: 5,
          ListId:5,
          t001: "主起升",
          t002: "工作循环次数",
          t003: "实数",
          t004: "19600",
          t005: "次",
          selected:false,
        },
        {
          Id: 6,
          ListId:6,
          t001: "主起升",
          t002: "主起电机1电流A",
          t003: "实数",
          t004: "2.30",
          t005: "A",
          selected:false,
        },
        {
          Id: 7,
          ListId:7,
          t001: "主起升",
          t002: "主起电机1电流B",
          t003: "实数",
          t004: "2.40",
          t005: "A",
          selected:false,
        },
        {
          Id: 8,
          ListId:8,
          t001: "主起升",
          t002: "主起电机1电流C",
          t003: "实数",
          t004: "2.20",
          t005: "A",
          selected:false,
        },
        {
          Id: 9,
          ListId:9,
          t001: "主起升",
          t002: "主起电机2电流A",
          t003: "实数",
          t004: "2.00",
          t005: "A",
          selected:false,
        },
        {
          Id: 10,
          ListId:10,
          t001: "主起升",
          t002: "主起电机2电流B",
          t003: "实数",
          t004: "2.40",
          t005: "A",
          selected:false,
        },
      ],
    };
  },
  filters: {
    userTypeFilter(type) {
      let typeText = type;
      userTypes.forEach((val) => {
        if (type === val.value) {
          typeText = val.name;
        }
      });
      return typeText;
    },
    menuFilter(ids) {
      let length = 0;
      if (ids) {
        length = ids.length;
      }
      return length;
    },
    dateTimeFilter(time) {
      return parseTime(time);
    },
  },
  mounted() {
    let _this = this; //声明一个变量指向vue实例this,保证作用域一致
    (this.timer = setInterval(function () {
      _this.date = new Date(); //修改数据date
    }, 1000)),
      console.log(this.$route.path); // 输出当前页面的路由，如：/home
  },
};
</script>

<style lang="less" scoped>
.headerbackgroud {
}
.allbody {
  width: 100%;
  height: 1050px;
}
.rowclass {
  width: 100%;
  height: 50%;
}

#text {
  -webkit-text-fill-color: white;
}
.select {
  color: white;
}
.hello {
  // 未选中任何选项的时候 placeholder的样式 需要先选中父元素 增加权重
  /deep/ input::-webkit-input-placeholder {
    color: #fff;
  }
  /deep/ input::-moz-input-placeholder {
    color: #fff;
  }
  /deep/ input::-ms-input-placeholder {
    color: #fff;
  }

  //修改的是el-input的样式
  //一种方法是设置最里层el-input__inner的背景色 外层的两级父元素设置为透明色
  //另一种方法是从el-select到el-input__inenr的背景色都设置为需要的颜色
  /deep/ .el-select,
  /deep/ .el-input,
  /deep/ .el-input__inner {
    background-color: #08164d;
    color: #fff;
    border: 0px;
    border-radius: 0px;
    text-align: center;
  }
}
.form-input /deep/ .el-input__inner {
  color: rgb(0, 0, 0) !important;
}
.map1,
.map2,
.map3 {
  position: absolute;
  opacity: 0.5;
}
.map1 {
  margin-left: 580px;
  margin-top: 230px;
  z-index: 2;
  animation: myfirst2 15s infinite linear;
}
.map2 {
  margin-left: 625px;
  margin-top: 275px;
  z-index: 3;
  opacity: 0.2;
  animation: myfirst 10s infinite linear;
}
.map3 {
  margin-left: 650px;
  margin-top: 300px;
  z-index: 1;
}
@keyframes myfirst2 {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(359deg);
  }
}

@keyframes myfirst {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-359deg);
  }
}
</style>
